package com.wq.ui;

import com.wq.biz.Dice;
import com.wq.ui.coms.BasicMenuPane;
import com.wq.ui.coms.ImageGet;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

@RequiredArgsConstructor(onConstructor_ = {@Autowired})
@Component
public class GamePanel extends BasicMenuPane {

    private final StartPanel startPanel;
    @PostConstruct
    public void inti(){
        render(2,false);
        setExitButton(0);
        setButtonLink(1, startPanel);
        setBounds(0, 0, 1000, 800);
        init(875, 628, 100, 50, 70, true);
        setNames(new String[]{"结束游戏", "返回"});
        setBackImage(ImageGet.getImageGet().getChessBoard());
        addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                if (!(e.getButton() == 1)) {
                    Dice.nextRoll++;
                    if (Dice.nextRoll > 6) {
                        Dice.nextRoll = 1;
                    }
                    System.out.println("control dice = " + Dice.nextRoll);
                }
                {
//					System.out.println("new Point("+e.getX()+","+e.getY()+"),");
//					ChessPane.testP = e.getPoint();
                }
            }
        });
    }
}
